package com.yd.app.service.pc.userCartService;

import com.yd.app.mapper.UserCartMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.ShoppingCart;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by bxd on 2018/3/21.
 */
@Service
public class UserCartService extends BaseService{

    @Autowired
    UserCartMapper userCartMapper;

    /**
     * 添加
     *
     */
    public void addCart(ShoppingCart shoppingCart) {
        userCartMapper.addCart(shoppingCart);
    }
    /**
     * @Author: zy
     * @Desc: 用户和商品id查询购物车
     * @Date:  2018/4/8
     * @Param
     */
    public ShoppingCart getCartByUGId(String userId,String goodsId,String goodsWeightId){
        ShoppingCart shoppingCart =new ShoppingCart();
        shoppingCart=userCartMapper.getCartByUGId(userId,goodsId,goodsWeightId);
        return shoppingCart;
    }
    /**
     * 修改
     *
     */
   /* public void updateCart(ShoppingCart shoppingCart) {
        userCartMapper.updateCart(shoppingCart);
    }*/

    /**
     * 删除
     *
     */
    public void deleteCart(String userId, String goodsId,String goodsWeightId) {
        userCartMapper.deleteCar(userId, goodsId,goodsWeightId);
    }

    /**
     * 查询用户购物车信息
     *
     */
    public List<ShoppingCart> getListCart(String userId) {
        List<ShoppingCart> listCart = userCartMapper.getListCart(userId);
        return listCart;
    }

    //修改商品购买数量
    public void updateCartNumber(String userId,String goodsId, int number) {
        userCartMapper.updateCartNumber(userId,goodsId,number);
    }
}
